package udp;

import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.InetAddress;

public class UdpClient {

	public static void main(String[] args) throws Exception{
		String sendInfo="I am attact bug!!!";
		DatagramPacket packet=new DatagramPacket(sendInfo.getBytes("UTF-8"), sendInfo.length());
		packet.setPort(9999);
		InetAddress address=InetAddress.getByName("127.0.0.1");
		packet.setAddress(address);
		
		DatagramSocket socket=new DatagramSocket();
		socket.send(packet);
		DatagramPacket recPacket=new DatagramPacket(new byte[256],256);
		socket.receive(recPacket);
		System.out.println(new String(recPacket.getData(),"UTF-8"));
		socket.close();

	}

}
